package net.xiangcaowuyu.springcloud.alibaba.seata.controller;

import lombok.extern.slf4j.Slf4j;
import net.xiangcaowuyu.springcloud.alibaba.seata.service.IStorageService;
import net.xiangcaowuyu.springcloud.entites.CommonResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 博客：https://www.xiangcaowuyu.net
 * Description:
 *
 * @Author: 香草物语
 * DateTime: 2021-07-25 21:13
 */
@RestController
@RequestMapping("/storage")
@Slf4j
public class StorageController {

    @Resource
    private IStorageService storageService;

    @PostMapping("/decrease")
    public CommonResult decrease(@RequestParam("productId") Long productId, @RequestParam("count") Integer count) {
        storageService.decrease(productId, count);
        return new CommonResult(200, "扣减库存成功");
    }

}
